//
//  CustomeTableViewController.m
//  TabbarTest
//
//  Created by guosm on 2021/4/20.
//

#import "CustomeTableViewController.h"

#import "ViewController.h"
#import "DMBottomView.h"
@interface CustomeTableViewController ()

@end

@implementation CustomeTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    
    
        NSArray *dict = @[
                                     @{@"selectedIcon":@"blue-ocean-select",
                                       @"defaultIcon":@"blue-ocean",
                                       @"name":@"蓝海",
//                                       @"link":[DMAPIConfig urlForKey:@"blueOcean"],
                                       @"native":@0
                                       },
                                     @{@"selectedIcon":@"business-select",
                                       @"defaultIcon":@"business",
                                       @"name":@"商机",
//                                       @"link":@"http://47.112.138.184:8080/dict-app-sz/mobile/market/index",
//                                       @"link":[DMAPIConfig urlForKey:@"business"],
                                       @"native":@0
                                       },
                                     
                                     @{@"selectedIcon":@"compete-select",
                                       @"defaultIcon":@"compete",
                                       @"name":@"竞争",
//                                       @"link":[DMAPIConfig urlForKey:@"compete"],
                                       @"native":@1
                                       },
                                     @{@"selectedIcon":@"special-select",
                                       @"defaultIcon":@"special",
                                       @"name":@"专题",
//                                       @"link":[DMAPIConfig urlForKey:@"special"],
                                       @"native":@1
                                       },
                                     @{@"selectedIcon":@"industry-select",
                                       @"defaultIcon":@"industry",
                                       @"name":@"行业",
//                                       @"link":@"http://47.112.138.184:8080/dict-app-sz/mobile/rival/index",
//                                       @"link":[DMAPIConfig urlForKey:@"industry"],
                                       @"native":@0
                                       },@{@"selectedIcon":@"industry-select",
                                           @"defaultIcon":@"industry",
                                           @"name":@"业务",
    //                                       @"link":@"http://47.112.138.184:8080/dict-app-sz/mobile/rival/index",
//                                           @"link":[DMAPIConfig urlForKey:@"yewu"],
                                           @"native":@0
                                           },];
    
    for (NSInteger i = 0; i<dict.count; i++) {
        NSDictionary *item = dict[i];
        UIViewController *vc = [[UIViewController alloc] init];
        vc.title = @(i).stringValue;
//        [vc.tabBarItem setImage:];
        vc.tabBarItem.title = nil;
        [self addChildViewController:vc];
    }
    CGFloat w = [UIScreen mainScreen].bounds.size.width;

    DMBottomView *v = [[DMBottomView alloc] initWithFrame:self.tabBar.bounds];
    v.tag = 99;
    [v setItems:dict];
    [self.tabBar addSubview:v];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.tabBar.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        NSLog(@"-=-=-%@",NSStringFromCGRect(obj.frame));
        if (obj.tag != 99) {
            obj.hidden = YES;
        }
    }];
}
@end
